package com.gcxy.exception.global;

import com.gcxy.core.R;
import com.gcxy.enums.ResultCodeEnum;
import com.gcxy.exception.annotation.GlobalException;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Copyright (C), 2024-2024, BUG闭退！
 * Author: Huang先森
 * Date: 2024/7/22 13:24
 * FileName: GlobalExceptionProcess
 * Description:
 */
@Slf4j
@GlobalException(priority = 0)
public class GlobalExceptionProcess implements IGlobalException<Object, Throwable> {

    @Override
    public R exception(Throwable throwable, HttpServletRequest request, HttpServletResponse response) {
        log.error("UnKnown exception: url={}", request.getRequestURI(), throwable);
        return R.Failed(throwable.getMessage());
    }
}